var bg = chrome.extension.getBackgroundPage();
var sqls = bg.getSQL();
var ul = document.getElementsByTagName('ul')[0];

function sendSQL(str) {
    bg.sendSQL(str)
}
function response(str) {
    console.log(str)
}
if (sqls.length > 0) {
    for(var i = 0; i < sqls.length; i++) {
        var li = document.createElement('li')
        var textarea = document.createElement('textarea')
        var a = document.createElement('a')
        textarea.value = sqls[i]
        a.innerHTML = 'Copy'
        a.setAttribute('data', sqls[i])
        a.onclick = function() {
            this.parentElement.children[0].select()
            // bg.sendSQL(this.getAttribute('data'))
            document.execCommand("Copy")
        }
        li.appendChild(textarea)
        li.appendChild(a)
        ul.appendChild(li)
    } 
} else {
    ul.innerHTML = '<div class="none">Input SQL as much as you like</div>'
}
